package org.jeecg.modules.demo.traderquota.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.jeecg.modules.demo.traderquota.entity.TraderQuota;

import java.util.List;

@Mapper
public interface TraderQuotaMapper extends BaseMapper<TraderQuota> {

    /**
     * 通过主表id查询子表数据
     *
     * @param mainId 主表id
     * @return List<Test2>
     */
    @Select("SELECT * FROM GC_TRADERQUOTA WHERE TRADERID = #{mainId}")
    List<TraderQuota> selectByMainId(@Param("mainId") String mainId);

    @Insert("INSERT INTO GC_TRADERQUOTA (ID,TRADERID,QUOTA_ADD,CREATE_TIME,CREATE_BY) VALUES(#{id},#{traderid},#{quotaAdd},#{createTime},#{createBy})")
    void insertQuota(TraderQuota traderQuota);

    @Select("SELECT SUM(QUOTA_ADD) FROM GC_TRADERQUOTA WHERE TRADERID = #{traderId}")
    Double countQuota(Integer traderId);


//    @Update("UPDATE TRADER SET QUOTA_TOTAL = #{quota} WHERE SYSID = #{id}")
//    void updateTraderQById(Integer id, Double quota);
}
